<?php
	include_once('../sys/sys.php');
	include_once('./178config.php');
	header('Content-Type: application/json; charset=utf-8');
	//获取系统内容以及分页
	
	//获取分类以及分页号
	$st = $_GET['st'];
	$name = trim($_GET['name']);
	if ($name == '') {
		$name = $_POST['name'];
	}
	if(is_null($st)){$st = 0;}
	//列出的图片数量(注意,不要超过15张)
	//$listnum = 60;
	
	$array_piclist = array();
	
	$DB->build_query(array(
			'select' 	=> 'id,name,lastupdate,count',
			'from'		=> '178_tags',
			'order'		=> 'lastupdate DESC',
			'where'		=> 'name like "%' . $name . '%"' ,
			'limit'		=> array($st,$listnum)
	));
	$qid = $DB->exec_query();
	$i = 0;
	$str = '{"dat": [';
	while ($row = $DB->fetch_row($qid)) {
		if($row['lastupdate'] <= 0) $row['lastupdate'] = 0;
		$str .= '{"nName": "' . trim($row['name']) . '","upDate": "' . get_date_time($row['lastupdate']) . '","id": "' . SITE_URL_MB . 'mb178/getpicfilespics' .$row['id'] . '.html"},';
		$i++;
	}
	//处理分页信息
	//获取总TAG数
	$totalnumbers = get_count_of_field('178_tags','name like "%' . $name . '%"');
	//$pagelink = $Elsesky->PageLinkR($st,$totalnumbers,$listnum,SITE_URL."178/search.php?name=" . $name . "&st=<:st:>");
	if($str != '{"dat": ['){
		$str = substr($str,0,strlen($str) - 1);
	}
	$str .= "]}";
	
	
	echo $str;
	
?>